#include<cstdio>
using namespace std;
int n,q,a[8001],x,v;
int sort(int x)
{
	int t=a[x],sum=0;
	for(int i=1;i<=n;i++){
		if(a[i]<t)
			sum++;
	}
	for(int i=1;i<=x;i++){
		if(a[i]==t){
			sum++;
		}
	}
	return sum;
}
int main()
{
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=q;i++){
		int y;
		scanf("%d",&y);
		if(y==1){
			scanf("%d%d",&x,&v);
			a[x]=v;
		}
		if(y==2){
			scanf("%d",&x);
			printf("%d\n",sort(x));
		}
	}
	return 0;
}
